package jwr;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class ButtonEventTest extends JFrame implements ActionListener{
	private JLabel result = new JLabel("");
	public ButtonEventTest() {
		JButton male = new JButton("남자");
		JButton female = new JButton("여자");
		JLabel jl = new JLabel("당신의 성별은?");
		
		Container ct = getContentPane();
		
		ct.setLayout(new FlowLayout());
		ct.add(male);
		ct.add(female);
		ct.add(jl);
		ct.add(result);
		male.addActionListener(this);
		female.addActionListener(this);
	}
	public static void main(String[] args) {
		ButtonEventTest bet = new ButtonEventTest();
		bet.setTitle("연습");
		bet.setSize(400,100);
		bet.setVisible(true);
		bet.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		result.setText(e.getActionCommand()); 
	}

}
